﻿using Microsoft.AspNet.SignalR;
using SharePointAccessMonitor.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SharePointAccessMonitor.Controllers
{
    public class LogController : Controller
    {

        public LogController()
        {
        }
        // GET: Log
        public ActionResult Write(string group, LogItem item)
        {
            if (group != null)
            {
                item.Timestamp = DateTime.Now;
                LogUtil.WriteLog(group, item);
                var hubContext = GlobalHost.ConnectionManager.GetHubContext<MonitorHub>();
                hubContext.Clients.Group(group).update(item);
            }
            return new HttpStatusCodeResult(200);
        }
    }
}